//app.js
var HttpUtil = require('/utils/httpUtil.js');
App({
  globalData: {
    userInfo: null,
  serverPath: "https://smarthealth.songlingyc.net",
   // serverPath: "http://192.168.31.244:9090/", 
    imagePath:"https://songling.oss-cn-beijing.aliyuncs.com/",
    isAuth: false,
    history: []
  },

  onLaunch: function () {
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    var userInfo = wx.getStorageSync('userInfo')
    this.globalData.userInfo = userInfo
    console.log("缓存的用户信息", this.globalData.userInfo)

    wx.getStorage({
      key: 'history',
      success: (res) => {
        this.globalData.history = res.data
      },
      fail: (res) => {
        console.log("get storage failed")
        console.log(res)
        this.globalData.history = []
      }
    })
  },
  onHide: function () {
    wx.stopBackgroundAudio()
  },
  initUserInfo: function () {//每个tab进去的时候都在onload中执行这个
    var cacheUserInfo = this.globalData.userInfo
    if (cacheUserInfo != null && cacheUserInfo != "") {//每次都查下用户信息
      return
    }
    var that = this
    wx.getSetting({
      success: function (res) {
        if (res.authSetting['scope.userInfo']) {

        } else {
          wx.navigateTo({
            url: '/pages/about/authorize/authorize',
           // url: '/pages/home/home',
          })

        }
      }
    })
  },


})